package com.guoxin.thread.extthread2.t1;

public class HasSelfPrivateNum {
    private int num = 0;//实例变量

    public synchronized void addI(String username) {
        // int num = 0; 局部变量不会出现非线程安全的问题
        if ("a".equals(username)) {
            num = 100;
            System.out.println("a set over!");
        } else {
            num = 200;
            System.out.println("b set over");
        }
        System.out.println(username + " num=" + num);
    }
}
